package com.example.xiaomiao.Mapper;

import com.example.xiaomiao.DO.Note;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.time.LocalDate;
import java.util.List;

@Mapper
public interface NoteMapper {
    void addNotes(@Param("id") int userId, @Param("date") LocalDate date, @Param("notes") List<String> notes);

    void deleteNotes(@Param("ids") List<Integer> noteIds);

    @Update("update note set note = #{note.note} where note_id = #{note.note_id}")
    void updateNote(@Param("note") Note note);

    @Select("select count(*) from note where user_id = #{id} and date = #{date}")
    int getNoteNum(@Param("id") int useId, @Param("date") LocalDate date);

    @Select("select note_id,note from note where user_id = #{id} and date = #{date} limit #{count} offset #{start}")
    List<Note> getNotes(@Param("id") int useId, @Param("date") LocalDate date, @Param("start") int start, @Param("count") int count);
}
